package com.dongdong.zhuangji.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
import com.nimbusds.jose.jwk.source.ImmutableSecret;
import com.nimbusds.jose.proc.SecurityContext;
/**
 * @author dongdong 抖音号：W13883155245
 * @version 1.0
 * @date 2025/6/9
 * @description
 */
@Configuration
public class SecurityConfig {

    @Bean
    public JwtDecoder jwtDecoder() {
        // 替换为你的对称密钥（需与生成 JWT 时使用的密钥相同）
        String secret = "zhuangji123";
        byte[] secretBytes = secret.getBytes();

        // 使用对称密钥创建 JwtDecoder
        return NimbusJwtDecoder.withSecretKey(new ImmutableSecret<>(secretBytes).getSecretKey()).build();
    }
}